import React from 'react';
import Mycontext from '../Mycontext';



export default class Son extends React.Component {
    constructor(props){
        super(props)
    }
    //告诉当前组件，你可以使用contextType上下文对象获取他的数据
    static contextType=Mycontext
    render(){
        console.log('son ',this.context);
        this.context.testMethod(' from son');
        return (
        
                <Mycontext.Consumer>
                    {
                        (value)=>{
                            return(
                                <div className='Son'>
                                    {value.msg}
                                </div>
                            )
                        }
                    }
                </Mycontext.Consumer>
         
          );
    }
  
}